package com.ruoyi.college.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.college.domain.LabOrgKindRelRoles;
import com.ruoyi.college.service.ILabOrgKindRelRolesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机构分类可用角色Controller
 * 
 * @author winner pan
 * @date 2022-02-13
 */
@RestController
@RequestMapping("/college/orgKindRoles")
public class LabOrgKindRelRolesController extends BaseController {
	@Autowired
	private ILabOrgKindRelRolesService labOrgKindRelRolesService;

	/**
	 * 查询机构分类可用角色列表
	 */
	@PreAuthorize("@ss.hasPermi('college:orgKindRoles:list')")
	@GetMapping("/list")
	public TableDataInfo list(LabOrgKindRelRoles labOrgKindRelRoles) {
		startPage();
		List<LabOrgKindRelRoles> list = labOrgKindRelRolesService.selectLabOrgKindRelRolesList(labOrgKindRelRoles);
		return getDataTable(list);
	}

	/**
	 * 导出机构分类可用角色列表
	 */
	@PreAuthorize("@ss.hasPermi('college:orgKindRoles:export')")
	@Log(title = "机构分类可用角色", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult export(LabOrgKindRelRoles labOrgKindRelRoles) {
		List<LabOrgKindRelRoles> list = labOrgKindRelRolesService.selectLabOrgKindRelRolesList(labOrgKindRelRoles);
		ExcelUtil<LabOrgKindRelRoles> util = new ExcelUtil<LabOrgKindRelRoles>(LabOrgKindRelRoles.class);
		return util.exportExcel(list, "orgKindRoles");
	}

	/**
	 * 获取机构分类可用角色详细信息
	 */
	@PreAuthorize("@ss.hasPermi('college:orgKindRoles:query')")
	@GetMapping(value = "/{orgKindRelRolesId}")
	public AjaxResult getInfo(@PathVariable("orgKindRelRolesId") Long orgKindRelRolesId) {
		return AjaxResult.success(labOrgKindRelRolesService.selectLabOrgKindRelRolesById(orgKindRelRolesId));
	}

	/**
	 * 新增机构分类可用角色
	 */
	@PreAuthorize("@ss.hasPermi('college:orgKindRoles:add')")
	@Log(title = "机构分类可用角色", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabOrgKindRelRoles labOrgKindRelRoles) {
		return toAjax(labOrgKindRelRolesService.insertLabOrgKindRelRoles(labOrgKindRelRoles));
	}

	/**
	 * 修改机构分类可用角色
	 */
	@PreAuthorize("@ss.hasPermi('college:orgKindRoles:edit')")
	@Log(title = "机构分类可用角色", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody LabOrgKindRelRoles labOrgKindRelRoles) {
		return toAjax(labOrgKindRelRolesService.updateLabOrgKindRelRoles(labOrgKindRelRoles));
	}

	/**
	 * 删除机构分类可用角色
	 */
	@PreAuthorize("@ss.hasPermi('college:orgKindRoles:remove')")
	@Log(title = "机构分类可用角色", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orgKindRelRolesIds}")
	public AjaxResult remove(@PathVariable Long[] orgKindRelRolesIds) {
		return toAjax(labOrgKindRelRolesService.deleteLabOrgKindRelRolesByIds(orgKindRelRolesIds));
	}
}
